<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="common_form.css">
</head>
<script>
    var flag=false;
    function check(str) {
        var a = document.getElementById(str);
        var b = document.getElementById(str + "Check");
        if (str == "username") {
            if (a.value == "")
                b.hidden = false;
            else b.hidden=true;
        }
        else if (str == "password") {
            L=a.value.length;
            if(L<6){
                b.hidden=false;
            } else {
                b.hidden=true;
            }
        }
        else if(str=="again"){
            var z=document.getElementById("password").value;
            if(z!=a.value){
                b.hidden=false;
            }
            else b.hidden=true;
        }
        else{
            if(a.value=="")
                b.hidden=false;
            else b.hidden=true;
        }
        flag=b.hidden;
        return b.hidden;
    }

    function onSubmit() {
        if(flag){
            var user=document.getElementById("username").value,
                psw=document.getElementById("password").value;
            for(var i=0;i<localStorage.length;i++){
                var getKey=localStorage.key(i);
                if(getKey.substring(0,6)=="userID"){
                    var str=localStorage.getItem(getKey);
                    var data=JSON.parse(str);
                    if(user==data.user&&psw==data.password) {
                        alert("登录成功！");
                        return;
                    }
                }
            }
            alert("用户名或密码不正确！");
            return;
        }
        alert("用户名或密码不正确！");
    }


</script>
<body>
<div class="content">
    <img class="content-logo" src="form_logo.jpg" alt="logo">
    <h1 class="content-title">登录</h1>
    <div class="content-form">
        <form method="post" onsubmit="return submitTest()">
            <div id="m1">
                <input class="user" type="text" name="user" id="username" placeholder="请输入用户名" onblur='check("username")'>
            </div>
            <p id="usernameCheck" class="check" hidden="true">用户名不能为空</p>
            <div id="m2">
                <input class="password" type="password" name="password" id="password" placeholder="请输入密码" onblur='check("password")'>
            </div>
            <p id="passwordCheck" class="check" hidden="true">密码不能为空</p>
            <div id="m3">
                <input class="content-form-signup" type="submit" value="登录" onclick='onSubmit()'>
            </div>
        </form>
    </div>
    <div class="conten-login-des">没有账户？</div>
    <div><a class="conten-login-link" href="signUp.html">立即注册</a> </div>
</div>
<script color='125,25,150' opacity='0.8' zIndex="-2" count="199" type="text/javascript" src="triangle.js"></script>
</body>
</html>